package sort;

/**
 * Created by pintec on 2017/5/31.
 *
 */
public class InsertSort {
    public static void main(String[] args) {
        int[] baseArray = {10, 1, 8, 6, 4, 6, 3, 5, 9};
        for (int i = 0; i < baseArray.length; i++) {
            int temp = baseArray[i];
            int flag = i;
            while (flag > 0 && baseArray[flag - 1] > temp) {
                baseArray[flag] = baseArray[flag - 1];
                --flag;
            }
            baseArray[flag] = temp;
        }
        for (int i = 0; i < baseArray.length; i++) {
            System.out.println(baseArray[i]);
        }
    }
}
